<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>jQuery UI Tabs - Default functionality</title>
        <jsp:include page="commons/commoncss.jsp"/>

		<jsp:include page="commons/commonjs.jsp" />
		
        <script type="text/javascript" charset="utf-8">
            function fnFormatDetails ( oTable, nTr )
            {
                var aData = oTable.fnGetData( nTr );
                var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
                sOut += '<tr><td>Gov Office Region Name:</td><td><input type="text" value="'+aData[1]+'" size="50"/></td></tr>';
                sOut += '<tr><td>Description: </td><td><textarea cols="47">'+aData[2]+'</textarea></td></tr>';
                sOut += '<tr><td>County:</td><td><ul><li>county 1 <a href="#">remove</a></li><li>county 2 <a href="#">remove</a></li></ul></td></tr>';
                sOut += '<tr><td></td><td><select><option>County 1</option><option>County 2</option></select> <input type="button" value="Add County"/></td></tr>';
                if(aData[3] == 'Yes')
                    sOut += '<tr><td>Is Active:</td><td><input type="radio" name="isActive" checked="checked"/>Yes <input type="radio" name="isActive" /> No</td></tr>';
                else
                    sOut += '<tr><td>Is Active:</td><td><input type="radio" name="isActive"/>Yes <input type="radio" name="isActive" checked="checked"/> No</td></tr>';
                sOut += '<tr><td></td><td><input type="button" value="Save"/><input type="button" value="Close"/></td></tr>';
                sOut += '</table>';

                return sOut;
            }
            $(document).ready(function() {
            	var oTable = $('#example').dataTable( {
                    "aoColumnDefs": [
                        { "bSortable": false, "aTargets": [ 0 ] }
                    ],
                    "aaSorting": [[1, 'asc']],
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "bProcessing": true,
					"bServerSide": true,
					"sAjaxSource": "gov_office_region.action"
                } );
                
                /* Add event listener for opening and closing details
                 * Note that the indicator for showing which row is open is not controlled by DataTables,
                 * rather it is done here
                 */
                $('#example tbody td img').live('click', function () {
                    var nTr = $(this).parents('tr')[0];
                    if ( oTable.fnIsOpen(nTr) )
                    {
                        /* This row is already open - close it */
                        this.src = "tablemedia/images/details_open.png";
                        oTable.fnClose( nTr );
                    }
                    else
                    {
                        /* Open this row */
                        this.src = "tablemedia/images/details_close.png";
                        oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
                    }
                } );

                $( "#dialog-form" ).dialog({
                    autoOpen: false,
                    height: 300,
                    width: 400,
                    modal: true
                });


                $( "#createGovButton" )
                .button()
                .click(function() {
                    $( "#dialog-form" ).dialog( "open" );
                });
                
            } );
        </script>
    </head>
    <body>
        <div id="container">
            <jsp:include page="commons/header.jsp" />
            <jsp:include page="commons/menubar.jsp"/>
            <div id="content">
                <div id="maincontent">
                    <div id="maincontentheader">
                        Goverment Office Region List
                    </div>
                    <div id="tabs">
                        <div class="ui-tabs-panel">
                            <div id="tablecontrols">
                                <span id="leftcontrols">
                                    <a href="#">All</a>
                                    <a href="#">|</a>
                                    <a href="#">A B C D E</a>
                                    <a href="#">|</a>
                                    <a href="#">F G H I J</a>
                                    <a href="#">|</a>
                                    <a href="#">K L M N</a>
                                    <a href="#">|</a>
                                    <a href="#">O P Q R</a>
                                    <a href="#">|</a>
                                    <a href="#">S T U V</a>
                                    <a href="#">|</a>
                                    <a href="#">W X Y Z</a>
                                </span>
                                <span id="rightcontrols">
                                    <button id="createGovButton">Create</button>
                                    <input type="checkbox"/><span>Include inactive</span>
                                </span>
                            </div>
                            <div>
                                <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
                                    <thead>
                                        <tr>
                                        	<th></th>
                                            <th>Gov Office Region Name</th>
                                            <th>Description</th>
                                            <th>Is Active?</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                        	<th></th>
                                            <th>Gov Office Region Name</th>
                                            <th>Description</th>
                                            <th>Is Active?</th>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <jsp:include page="commons/footer.jsp"/>
        </div>


        <div id="dialog-form" title="Create new Goverment Office Region"
             style="font-size: 14px;">
            <p class="validateTips">All form fields are required.</p>
            <form>
                <table width="100%">
                    <tr>
                        <td>
                            <label for="name">Name</label>
                        </td>
                        <td>
                            <input type="text" name="name" id="name"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="description">Description</label>
                        </td>
                        <td>
                            <textarea cols="17"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="county">County</label>
                        </td>
                        <td>
                            <select>
                                <option>County 1</option>
                                <option>County 2</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>Is active</label>
                        </td>
                        <td>
                            <input type="radio" checked="checked" name="isactive"/>Yes
                            <input type="radio" name="isactive"/>No
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="button" value="Create"/>
                            <input type="button" value="Cancel"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </body>
</html>

